package com.copa.l1759;

/**
 * @author copa
 * @createDate 2022-12-26 16:32
 * @function 双指针法
 */
public class Test1 {

    public int countHomogenous(String s) {
        // 为啥这样搞？看题目要求！我就是错在这里了！
        int MOD = 1000000007;
        if (s.length() == 1) {
            return 1;
        }
        long result = 0;
        int min = 0;
        int max = 0;
        int n;
        while (min < s.length()){
            if (max + 1 < s.length() && s.charAt(max + 1) == s.charAt(min)) {
                max++;
                continue;
            }
            n = max - min + 1;
            result += (long)(1 + n) * n / 2;
            min = max + 1;
            max = min;
        }
        return (int) (result % MOD);
    }

    public static void main(String[] args) {
        //String s = "abbcccaa";
        //String s = "xy";
        String s = "vvvvvvllll";
        System.out.println(new Test1().countHomogenous(s));
    }
}
